Get premium membership and access questions with answers, video lessons as well as revision papers.

Given the following class definition, class test{ char *p; int *q; int count; public: test(char *x, int *y, int c) { p = x; q = y; count = c; } //... }; Is it possible...

      

Given the following class definition,
class test{
char *p;
int *q;
int count;
public:
test(char *x, int *y, int c) {
p = x;
q = y;
count = c;
}
//...
};
Is it possible to dynamically allocate an array of these objects?

  

Answers


Davis

No, because there is no way to initialize a dynamic array. This class has only one constructor, and it requires initializers.

Githiari answered the question on May 31, 2018 at 18:06


Next: Given the following partial class, add the necessary constructor function so that both declarations within main() are valid. class samp { int a; public: //add constructor functions int get_a() {...
Previous: What is wrong with the following function prototype? char *f(char *p, int x =0, char *q);

View More Computer Studies Questions and Answers | Return to Questions Index


Learn High School English on YouTube

Related Questions